home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
cvt100.zip
/
VIDIO.C
< prev
next >
Wrap
Text File
|
1988-08-03
|
47KB
|
1,101 lines
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <alloc.h>
#define NORMAL 0x7 /* Normal video attribute */
#define BOLD 0x8 /* Bold video attribute */
#define UNDERLINED 0xA /* Underlined video attribute */
#define REVERSE 0x70 /* Reverse video attribute */
#define SCREEN 0x10 /* BIOS video interrupt number */
#define RETRACE 0x3da /* Video Retrace port address for CGA */
#define ASCII 0 /* ASCII character set */
#define UK 1 /* UK character set */
#define SPECIAL 2 /* Special character set, graphics chars */
/****************************************************************************/
/* Function prototypes */
void VidInit( void ); /* Initialize the video system */
void SetVattr( unsigned char ); /* Set the video attribute */
void AddVattr( unsigned char ); /* Add attribute to current video attribute*/
void SubVattr( unsigned char ); /* Sub attribute from current vid attribute*/
void BrkAtt( unsigned char ); /* Break attribute into extra and base */
unsigned char AddAtt( void ); /* Add extra and base attributes to get */
/* a resulting displayable video attribute*/
void ChrWrite( unsigned char ); /* Write character to the screen */
void SetScroll(int , int ); /* Set the scrolling region */
void ScrollDown( void ); /* Move down a row scrolling if necessary */
void ScrollUp( void ); /* Move up a row scrolling if necessary */
void IndexDown( void ); /* Scroll the screen down */
void IndexUp( void ); /* Scroll the screen up */
void SetCurs(int , int ); /* Set the cursor to absolute coordinates */
void SetRelCurs(int , int ); /* Set the cursor to relative coordinates */
void PosCurs( void ); /* Position the cursor to cursx,cursy */
void ModeLine( void ); /* Display the Mode line */
void ClearScreen( void ); /* Clear the terminal screen */
void ClearEOS( void ); /* Clear from cursor to end of screen */
void ClearBOS( void ); /* Clear from cursor to top of screen */
void ClearEOL( void ); /* Clear from cursor to end of line */
void ClearBOL( void ); /* Clear from cursor to start of line */
void ClearBox( unsigned char, /* Clear a box on the video screen */
unsigned char, unsigned char,
unsigned char, unsigned char);
void MarCharSet( int ); /* Map a character set */
void SetCharSet( int, unsigned char ); /* Set a character set */
void SaveCursor( void ); /* Save the cursor description */
void RestoreCursor( void ); /* Restore the cursor description */
void SetCursorVisibility( int ); /* Set the cursor visibility mode */
void SetBackGround( int ); /* Set background video attribute */
void SetColor( void ); /* Set the screen colors */
void InitTabs( void ); /* Initialize the tab settings */
void DoTab( void ); /* Perform a tab */
void SetTabStop( void ); /* Set a tab stop at cursor position */
void ClearTabStop( void ); /* Clear a tab stop at the cursor position*/
void ClearAllTabs( void ); /* Clear all the defined tab stops */
void SetScreenWidth( int ); /* Set the logical width of the screen */
void StartScreen( int, int ); /* Start a screen access */
void EndScreen( void ); /* End a screen access */
void WriteOneChar( unsigned char, /* Write one character to the screen */
int, int );
int VTprintf( int, int, int, /* Printf for Emulator to row and column */
char *, ... ); /* in regular or reverse video */
void SaveScreen( void ); /* Save contents of video memory */
void RestoreScreen( void ); /* Restore contents of video memory */
static void interrupt10( unsigned,/* Issue a BIOS video interrupt */
unsigned , unsigned , unsigned );
/****************************************************************************/
/* Global Data */
unsigned char retracemode = 0; /* Flag indicating No Video refresh wait */
unsigned char forecolor; /* Foreground color */
unsigned char backcolor; /* Background color */
unsigned char vidmode; /* Screen video mode */
/****************************************************************************/
/* External variables */
extern unsigned originmode; /* Origin mode, relative or absolute */
extern unsigned insertmode; /* Insert mode, off or on */
extern unsigned autowrap; /* Automatic wrap mode, off or on */
extern unsigned newline; /* Newline mode, off or on, GLOBAL data!*/
extern unsigned cursorvisible; /* Cursor visibility, on or hidden */
extern unsigned reversebackground;/* Reverse background attribute, on or off*/
extern unsigned screenwid; /* Absolute screen width */
extern char modeline[]; /* Text of mode line */
/***************************************************************************/
/* Local static data */
static unsigned char screentop; /* Absolute top of screen */
static unsigned char screenbot; /* Absolute bottom of screen */
static unsigned char scrolltop; /* Top row of scrolling region */
static unsigned char scrollbot; /* Bottom row of scrolling region */
static int cursx; /* X cursor position */
static int cursy; /* Y cursor position */
static unsigned scroff; /* Screen memory offset */
static unsigned scrseg; /* Screen memory segment */
static unsigned scrchars; /* Number of chars written to video memory */
static unsigned char tvmode; /* Flag to indicate control program present*/
char far *screen; /* Pointer to video screen */
static unsigned savebp; /* Static storage for BP through int 0x10 */
static unsigned char video_state; /* State of video, reversed or normal */
static unsigned char scbattr; /* Video attribute of empty video cell */
static unsigned char curattr; /* Video attribute of displayable chars */
static unsigned char baseattr; /* Base attribute for video attributes */
static unsigned char extrattr; /* Extra attribute for video attributes */
static unsigned char att_reverse; /* Reverse attribute bits */
static unsigned char att_normal; /* Normal attribute bits */
static unsigned char att_low_mask = 0x6; /* Low attribute mask */
static unsigned char att_underline = 0x1; /* Underlined attribute bit */
static unsigned char att_intensity = 0x8; /* Bold attribute bit */
static unsigned char att_blink = 0x80; /* Blinking attribute bit */
static unsigned columns; /* Columns on logical terminal screen */
static unsigned lines; /* Lines on logical terminal screen */
static char tabs[132]; /* active tab stops */
static char deftabs[132]; /* default tab stops, 9,17,26 .... */
static int G0 = ASCII; /* Character set G0 */
static int G1 = ASCII; /* Character set G1 */
static int *GL = &G0; /* Pointer to current mapped character set*/
static char special_chars[32] = { /* Special characters */
32,4,176,9,12,13,10,248,241,18,11,217,191,218,192,197,
196,196,196,196,196,195,180,193,194,179,243,242,227,216,156,7
} ;
static struct SaveCursorStruct { /* Structure to save cursor description */
int cursx; /* X cursor position, column */
int cursy; /* Y cursor position, row */
int *GL; /* pointer to mapped character set */
int G0; /* character set G0 */
int G1; /* character set G1 */